package com.car.dao.impl;


import com.car.dao.AdminPageCarDao;
import com.car.domain.Car;
import com.car.utils.JDBCUtil;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

import java.util.List;

public class AdminPagCarDaoImpl implements AdminPageCarDao {
    JdbcTemplate jt=new JdbcTemplate(JDBCUtil.getDs());
    @Override
    public List<Car> adminPageCar(Integer s, Integer size) {
        String sql="select * from tab_car limit ?,?";
        List<Car> query = jt.query(sql, new BeanPropertyRowMapper<Car>(Car.class),
                (s-1)*size, size);
        return query;
    }

    @Override
    public Number adminCarAllCount() {
        String sql="select count(cid) from tab_car";
        Number number = jt.queryForObject(sql, Number.class);
        return number;
    }
}
